
 const countdowm = (timestamp,func) => {
 	let timer = setInterval(function() {   
		let t = timestamp
		if(t > 0) {          
			let day = Math.floor(t /60 / 60 / 24);          
			let hour = Math.floor(t / 60 / 60 % 24);          
			let min = Math.floor(t / 60 % 60);          
			let sec = Math.floor(t % 60);          
			hour = hour < 10 ? "0" + hour : hour;          
			min = min < 10 ? "0" + min : min;          
			sec = sec < 10 ? "0" + sec : sec;          
			let format = '';          
			if(day > 0) {            
				format = `${day}天${hour}小时${min}分${sec}秒`;          
			}          
			if(day <= 0 && hour > 0) {            
				format = `${hour}小时${min}分${sec}秒`;          
			}          
			if(day <= 0 && hour <= 0) {            
				format = `${min}分${sec}秒`;          
			}         
			--timestamp;  
			func(format);
			
		} else {           
			clearInterval(timer);  
			func("活动已结束!"); 
		}         
	}, 1000);  
 } 
 const splitParams = (str)=> {
        let ret = {},
            seg = str.replace(/^\?/, '').split('&'),
            len = seg.length, i = 0, s;
        for (; i < len; i++) {
            if (!seg[i]) { continue; }
            s = seg[i].split('=');
            ret[s[0].toLowerCase()] = s[1];
        }
        return ret;
   } 
const getDomain=()=>{
    //Chrome浏览器支持location.origin直接获取域名 但有些浏览器(IE)不支持
    var port = location.port;
    if (port) {
        port = ":" + port;
    }
    return location.protocol + '//' + location.hostname + port;
}


export{
  countdowm,
  splitParams,
  getDomain
}